import { getProfileAPI } from '@/api/user'
import {routes} from '@/router/index'
export default {
  namespaced: true,
  state: () => {
    return {
      profile: [],
      menuList:[]
    }
  },
  mutations: {
    setProfile(state, profile) {
      state.profile = profile
    },
    setMenuList(state,newPermission){
        console.log(routes)
        state.menuList = routes.concat(newPermission)
    },
    clearMenuList(state){
        state.menuList = []
    }
  },
  actions: {
    async getProfile(ctx) {
      const res = await getProfileAPI()
      ctx.commit('setProfile', res.data)
      return res.data.permissions
    }
  }
}